package com.webchat.ugc.messaegqueue.consumer.rocketmq;

import com.webchat.common.util.JsonUtil;
import com.webchat.domain.dto.queue.ChatAccountListMessageDTO;
import com.webchat.ugc.service.mall.im.MallChatAccountService;
import com.webchat.ugc.service.mall.im.MallChatMessageService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * 电商客服系统对话消息持久化RocketMQ队列
 *
 */
@Component
@RocketMQMessageListener(consumerGroup = "save_mall_message_group",
                         topic = "queue_ugc_persistent_mall_im_message")
public class MallChatMessageSaveRocketMQConsumer implements RocketMQListener<String> {


    @Autowired
    private MallChatMessageService mallChatMessageService;

    /**
     * 消息持久化
     * @param message
     */
    @Override
    public void onMessage(String message) {
        System.out.println("Received message: " + message);

        mallChatMessageService.doSaveMessage2Mongo(message);
    }
}